package app.modules.infrastructure.profile.facade;

import app.modules.infrastructure.profile.persistence.dao.ProfileValueDAO;
import app.modules.infrastructure.profile.persistence.entity.ProfileValueEO;
import jasmine.framework.context.CurrentSubject;
import org.springframework.stereotype.Component;

/**
 * @author mh.z
 */
@Component
public class ProfileFacadeImpl implements ProfileFacade {
    private ProfileValueDAO profileValueDAO;

    public ProfileFacadeImpl(ProfileValueDAO profileValueDAO) {
        this.profileValueDAO = profileValueDAO;
    }

    @Override
    public String getProfileValue(String profileName) {
        Long tenantId = CurrentSubject.getTenantId();
        Long userId = CurrentSubject.getUserId();

        ProfileValueEO profileValueEO = profileValueDAO.getProfileValueByProfileName(profileName, tenantId, userId);
        if (profileValueEO == null) {
            return null;
        }

        return profileValueEO.getValueCode();
    }

}
